package com.yyx.qq;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import edu.tsinghua.lumaqq.qq.Util;

public class AndroidQQ extends Activity implements OnClickListener {

	private static final String TAG = "AndroidQQ";

	private View loginButton;
	private EditText field_qqnum;
	private EditText field_qqpsw;
	private ImageButton qqpwdimg;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		findViews();
		setListeners();
	}

	// 查找视图元素
	private void findViews() {
		loginButton = findViewById(R.id.login);
		field_qqnum = (EditText) this.findViewById(R.id.qqnum);
		field_qqpsw = (EditText) this.findViewById(R.id.qqpsw);
		qqpwdimg = (ImageButton)this.findViewById(R.id.qqpwdimg);
		
	}

	// 视图元素设置事件监听
	private void setListeners() {
		loginButton.setOnClickListener(this);
	}

	/**
	 * 为按钮添加监听
	 */
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.login:
			int qqnum = Util.getInt(field_qqnum.getText().toString(), -1);
			String qqpwd = field_qqpsw.getText().toString();
			// Bundle数据容器类，类似于key/value键值对，但比之更强大 
            Bundle myBundle = new Bundle(); 
            myBundle.putInt("qqNum", qqnum); 
            myBundle.putString("qqPwd", qqpwd); 
            Intent i = new Intent(this, QQMain.class);
            i.putExtras(myBundle);
			startActivity(i);
		case R.id.qqpwdimg:
			field_qqpsw.setPressed(true);
		case R.id.reset:
			this.finish();
		}
	}


}